<template>
	<view></view>
	<z-paging ref="paging" v-model="records" @query="queryList">
		<uni-card v-for="(r,index) in records" :key="index" @click="recordDetail(r)">
			<text>{{r.question.content}}</text>
			<view>
				<uni-tag :text="r.question.subject" type="primary"></uni-tag>
				<uni-tag :text="r.question.category" type="success" style="margin-left: 8px;"></uni-tag>
			</view>
		</uni-card>
	</z-paging>
</template>

<script setup>
	import {
		ref,
		getCurrentInstance
	} from 'vue';
	import {
		getAllRecords
	} from '../../utils/api';
	const {
		proxy
	} = getCurrentInstance()
	let records = ref([])
	let paging = ref(null)

	function recordDetail(data) {
		uni.setStorage({
			key: 'record_item',
			data: data,
			success() {
				uni.navigateTo({
					url: '/pages/record_details/record_details'
				})
			}
		})
	}

	function queryList(pageNo, pageSize) {
		uni.showLoading({
			title: '正在加载历史数据'
		})
		getAllRecords(pageNo).then(res => {
			proxy.$refs.paging.complete(res)
		}).catch(err => {
			proxy.$refs.paging.complete(false)
		})
	}
</script>

<style>

</style>